import { createHashRouter } from 'react-router-dom';
import appRoutes, { AppRoutes } from './modules/app';

export const routerQuery = (path: string, routes: AppRoutes[] = appRoutes): AppRoutes | null => {
    for (let route of routes) {
      if (route.path === path) {
        return route;
      }
      if (route.children) {
        const foundRoute = routerQuery(path, route.children);
        if (foundRoute) {
          return foundRoute;
        }
      }
    }
    return null;
  };

const router = createHashRouter(appRoutes as any);

export default router;
